from utils.sendmethod import Send_Method
from interface.shopping_process import ShoppingProcess


class UmsOrderPartal(Send_Method):
    mall_ip = "http://47.108.206.100:8085"

    def cancelTimeout(self):
        """取消单个超时订单"""
        url = self.mall_ip.join('/order/cancelOrder')
        body = {'orderId': ShoppingProcess.generate_order()}
        token = {'token': self.sso_login()}
        return self.send_Method(method='post', url=url, headers=token, data=body)

    def automaticCancel(self):
        """自动取消超时订单"""
        url = self.mall_ip.join('order/cancelTimeOutOrder')
        token = {'token': self.sso_login()}
        return self.send_Method(method='post', url=url, headers=token)

    def user_cancels_order(self):
        """用户取消订单"""
        url = self.mall_ip.join('/order/cancelUserOrder')
        token = {'token': self.sso_login()}
        body = {'orderId': ShoppingProcess.generate_order()}
        return self.send_Method(method='post', url=url, headers=token, data=body)

    def get_order_details(self):
        """更具订单获取订单详情"""
        url = self.mall_ip.join('/order/detail')
        token = {'token': self.sso_login()}
        body = {'orderId': ShoppingProcess.generate_order()}
        return self.send_Method(method='post', url=url, headers=token, data=body)
